<template>
    <div>
        <!-- 机构管理 -->
        <div class="all-container">
            <el-row>
                <!-- 表格菜单栏 -->
                <el-col :span="24" class="table-fun">
                    <img src="../../assets/imgs/operation_icon_shuaxin_default.png" alt="" class="lf">
                    <div class="lf choose-title fun-text" @click="refresh">刷新</div>
                    <img src="../../assets/imgs/operation_icon_tianjia_default.png" alt="" class="lf">
                    <div class="lf choose-title fun-text" @click="add">添加</div>
                    <img src="../../assets/imgs/operation_icon_xiugai_default.png" alt="" class="lf">
                    <div class="lf choose-title fun-text" @click="mod">修改</div>
                    <img src="../../assets/imgs/operation_icon_shanchu_default.png" alt="" class="lf">
                    <div class="lf choose-title fun-text" @click="del">删除</div>
                </el-col>
            </el-row>
            <!-- 数据表格栏 -->
            <el-row>
                <el-col :span="24">
                    <!-- <avue-crud :data="orgList[0].data" :option="orgList[0].option" @current-row-change="rowChange" :page="orgList.page"></avue-crud> -->
                    <avue-tree-table :option="orgList[0].option" @current-row-change="rowChange"></avue-tree-table>
                </el-col>
            </el-row>
            <!-- 添加弹窗 -->
            <div v-show="addWin" class="addModal">
                <!-- 标题栏 -->
                <el-row class="add-title">
                    <div class="closeWin" @click="closeAddWin">X</div>
                    <el-col :span="24">
                        <img src="../../assets/imgs/operation_bg_biaoti_default.png" alt=""><span
                            class="add-text">添加</span>
                    </el-col>
                </el-row>
                <!-- 表单栏 -->
                <el-row class="form-container">
                    <el-col :span="24">
                        <!-- 第一行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">机构编码</div>
                                <el-input v-model="classID" placeholder="" size="mini" style="width:150px;"
                                          class="lf choose-input org-input"></el-input>
                                <div class="lf choose-title org-title">机构类型</div>
                                <el-select v-model="orgType" placeholder="" size="mini" style="width:150px;"
                                           class="lf choose-input org-input">
                                    <el-option :label="item.label" :value="item.value"
                                               v-for="item of orgTypeList"></el-option>
                                </el-select>
                                <div class="lf choose-title org-title">父机构</div>
                                <el-select v-model="fatherOrgType" placeholder="" size="mini" style="width:150px;"
                                           class="lf choose-input org-input">
                                    <el-option :label="it.label" :value="it.value"
                                               v-for="it of fatherOrgList"></el-option>
                                </el-select>
                            </el-col>
                        </el-row>
                        <!-- 第二行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">简称&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </div>
                                <el-input v-model="simpleID" placeholder="" size="mini" style="width:150px;"
                                          class="lf choose-input org-input"></el-input>
                                <div class="lf choose-title org-title">全称&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </div>
                                <el-input v-model="fullID" placeholder="" size="mini" style="width:450px;"
                                          class="lf choose-input org-input"></el-input>
                            </el-col>
                        </el-row>
                        <!-- 第三行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">标识码&nbsp;&nbsp;&nbsp;</div>
                                <el-input v-model="regID" placeholder="" size="mini" style="width:150px;"
                                          class="lf choose-input org-input"></el-input>
                                <div class="lf choose-title org-title">字体颜色</div>
                                <el-color-picker v-model="fontColor" size="mini" style="width:150px;"
                                                 class="lf choose-input org-input"></el-color-picker>
                                <div class="lf choose-title org-title">背景颜色</div>
                                <el-color-picker v-model="bgColor" size="mini" style="width:150px;"
                                                 class="lf choose-input org-input"></el-color-picker>
                            </el-col>
                        </el-row>
                        <!-- 第四行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">联系人&nbsp;&nbsp;&nbsp;</div>
                                <el-input v-model="contactMan" placeholder="" size="mini" style="width:150px;"
                                          class="lf choose-input org-input"></el-input>
                                <div class="lf choose-title org-title">联系电话&nbsp;</div>
                                <el-input v-model="contactPhone" placeholder="" size="mini" style="width:150px;"
                                          class="lf choose-input org-input"></el-input>
                            </el-col>
                        </el-row>
                        <!-- 第五行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">单位&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                <el-input v-model="comp" placeholder="" size="mini" style="width:300px;"
                                          class="lf choose-input org-input"></el-input>
                                <div class="lf choose-title org-title">地址&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                <el-input v-model="address" placeholder="" size="mini" style="width:300px;"
                                          class="lf choose-input org-input"></el-input>
                            </el-col>
                        </el-row>
                        <!-- 第六行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">备注&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                <el-input v-model="remark" placeholder="" size="mini" style="width:772px;"
                                          class="lf choose-input org-input"></el-input>
                            </el-col>
                        </el-row>
                        <!-- 第七行 -->
                        <el-row class="org-rowsII">
                            <el-col :span="24">
                                <div class="lf">
                                    <div class="choose-title org-title">数据关&nbsp;&nbsp;&nbsp;</div>
                                    <div class="choose-title org-title">联设置&nbsp;&nbsp;&nbsp;</div>
                                </div>
                                <div class="lf dataSet-container">
                                    <!-- 第一行 -->
                                    <el-row class="org-rows org-rowsII">
                                        <el-col :span="24">
                                            <div class="lf choose-title org-title">关联级别</div>
                                            <el-select v-model="orgType" placeholder="" size="mini" style="width:150px;"
                                                       class="lf choose-input org-input">
                                                <el-option label="不关联" value="0"></el-option>
                                                <el-option label="关联" value="1"></el-option>
                                            </el-select>
                                        </el-col>
                                    </el-row>
                                    <!-- 第二行 -->
                                    <el-row class="tag-line">
                                        <el-col :span="24">
                                            <div class="lf choose-title org-title">关联机构</div>
                                            <el-select v-model="orgType" placeholder="" size="mini" style="width:600px;"
                                                       class="lf choose-input org-input">
                                                <el-option v-for="item of guanLianOrgList" :label="item.name_full"
                                                           :value="item.no"></el-option>
                                            </el-select>
                                        </el-col>
                                    </el-row>
                                    <!-- 第三行 功能栏 -->
                                    <el-row>
                                        <el-col :span="24" class="table-fun">
                                            <img src="../../assets/imgs/operation_icon_tianjia_default.png" alt=""
                                                 class="lf">
                                            <div class="lf choose-title fun-text">添加</div>
                                            <img src="../../assets/imgs/operation_icon_shanchu_default.png" alt=""
                                                 class="lf">
                                            <div class="lf choose-title fun-text">删除</div>
                                            <img src="../../assets/imgs/Radio_icon_yingyong_default.png" alt=""
                                                 class="lf">
                                            <div class="lf choose-title fun-text">应用</div>
                                        </el-col>
                                    </el-row>
                                    <!-- 数据表格栏 -->
                                    <el-row>
                                        <el-col :span="24" class="contactList-container">
                                            <el-table
                                                    :data="contactList"
                                                    stripe
                                                    style="width: 100%">
                                                <el-table-column
                                                        prop="name"
                                                        label="机构"
                                                        width="250">
                                                </el-table-column>
                                                <el-table-column
                                                        prop="pid"
                                                        label="关联项"
                                                >
                                                </el-table-column>
                                            </el-table>
                                        </el-col>
                                    </el-row>
                                    <!-- 第五行 -->
                                    <el-row class="org-rows">
                                        <el-col :span="24">
                                            <el-select v-model="jiGou" placeholder="" class="lf choose-input org-input"
                                                       size="mini">
                                                <el-option v-for="item of guanLianOrgList" :label="item.name_full"
                                                           :value="item.no"></el-option>
                                            </el-select>
                                            <el-select v-model="sellType" placeholder="" class="rf choose-input"
                                                       size="mini" style="width:450px">
                                                <el-option label="优惠类型定义，售票" value="1"></el-option>
                                                <el-option label="test1" value="2"></el-option>
                                                <el-option label="test2" value="3"></el-option>
                                                <el-option label="test3" value="4"></el-option>
                                            </el-select>
                                        </el-col>
                                    </el-row>
                                </div>
                            </el-col>
                        </el-row>
                    </el-col>
                </el-row>
                <!-- 按钮 -->
                <button class="check-btn rf rows-btn" @click="cancel">
                    <img src="../../assets/imgs/operation_btn_icon_quxiao_default.png" alt="" class="btn-img">取消
                </button>
                <button class="check-btn rf rows-btn" @click="confirm"><img
                        src="../../assets/imgs/operation_btn_icon_tijiao_default.png" alt="" class="btn-img">确认
                </button>
            </div>
            <!-- 修改弹窗 -->
            <div v-show="modWin" class="addModal">
                <!-- 标题栏 -->
                <el-row class="add-title">
                    <div class="closeWin" @click="closeModWin">X</div>
                    <el-col :span="24">
                        <img src="../../assets/imgs/operation_bg_biaoti_default.png" alt=""><span
                            class="add-text">修改</span>
                    </el-col>
                </el-row>
                <!-- 表单栏 -->
                <el-row class="form-container">
                    <el-col :span="24">
                        <!-- 第一行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">机构编码</div>
                                <el-input v-model="classID" placeholder="" size="mini" style="width:150px;"
                                          class="lf choose-input org-input"></el-input>
                                <div class="lf choose-title org-title">机构类型</div>
                                <el-select v-model="orgType" placeholder="" size="mini" style="width:150px;"
                                           class="lf choose-input org-input">
                                    <el-option :label="item.label" :value="item.value"
                                               v-for="item of orgTypeList"></el-option>
                                </el-select>
                                <div class="lf choose-title org-title">父机构</div>
                                <el-select v-model="fatherOrgType" placeholder="" size="mini" style="width:150px;"
                                           class="lf choose-input org-input">
                                    <el-option :label="it.label" :value="it.value"
                                               v-for="it of fatherOrgList"></el-option>
                                </el-select>
                            </el-col>
                        </el-row>
                        <!-- 第二行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">简称&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </div>
                                <el-input v-model="classID" placeholder="" size="mini" style="width:150px;"
                                          class="lf choose-input org-input"></el-input>
                                <div class="lf choose-title org-title">全称&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </div>
                                <el-input v-model="classID" placeholder="" size="mini" style="width:450px;"
                                          class="lf choose-input org-input"></el-input>
                            </el-col>
                        </el-row>
                        <!-- 第三行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">标识码&nbsp;&nbsp;&nbsp;</div>
                                <el-input v-model="regID" placeholder="" size="mini" style="width:150px;"
                                          class="lf choose-input org-input"></el-input>
                                <div class="lf choose-title org-title">字体颜色</div>
                                <el-color-picker v-model="fontColor" size="mini" style="width:150px;"
                                                 class="lf choose-input org-input"></el-color-picker>
                                <div class="lf choose-title org-title">背景颜色</div>
                                <el-color-picker v-model="bgColor" size="mini" style="width:150px;"
                                                 class="lf choose-input org-input"></el-color-picker>
                            </el-col>
                        </el-row>
                        <!-- 第四行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">联系人&nbsp;&nbsp;&nbsp;</div>
                                <el-input v-model="contactMan" placeholder="" size="mini" style="width:150px;"
                                          class="lf choose-input org-input"></el-input>
                                <div class="lf choose-title org-title">联系电话&nbsp;</div>
                                <el-input v-model="contactPhone" placeholder="" size="mini" style="width:150px;"
                                          class="lf choose-input org-input"></el-input>
                            </el-col>
                        </el-row>
                        <!-- 第五行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">单位&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                <el-input v-model="contactMan" placeholder="" size="mini" style="width:300px;"
                                          class="lf choose-input org-input"></el-input>
                                <div class="lf choose-title org-title">地址&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                <el-input v-model="contactPhone" placeholder="" size="mini" style="width:300px;"
                                          class="lf choose-input org-input"></el-input>
                            </el-col>
                        </el-row>
                        <!-- 第六行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf choose-title org-title">备注&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                <el-input v-model="remark" placeholder="" size="mini" style="width:772px;"
                                          class="lf choose-input org-input"></el-input>
                            </el-col>
                        </el-row>
                        <!-- 第七行 -->
                        <el-row class="org-rows">
                            <el-col :span="24">
                                <div class="lf">
                                    <div class="choose-title org-title">数据关&nbsp;&nbsp;&nbsp;</div>
                                    <div class="choose-title org-title">联设置&nbsp;&nbsp;&nbsp;</div>
                                </div>
                                <div class="lf dataSet-container">
                                    <!-- 第一行 -->
                                    <el-row class="org-rows">
                                        <el-col :span="24">
                                            <div class="lf choose-title org-title">关联级别</div>
                                            <el-select v-model="orgType" placeholder="" size="mini" style="width:150px;"
                                                       class="lf choose-input org-input">
                                                <el-option label="关联基础数据" value="1"></el-option>
                                                <el-option label="关联基础数据" value="2"></el-option>
                                                <el-option label="关联基础数据" value="3"></el-option>
                                            </el-select>
                                        </el-col>
                                    </el-row>
                                    <!-- 第二行 -->
                                    <el-row class="tag-line">
                                        <el-col :span="24">
                                            <div class="lf choose-title org-title">关联机构</div>
                                            <el-select v-model="orgType" placeholder="" size="mini" style="width:600px;"
                                                       class="lf choose-input org-input">
                                                <el-option label="test1" value="1"></el-option>
                                                <el-option label="test2" value="2"></el-option>
                                                <el-option label="test3" value="3"></el-option>
                                            </el-select>
                                        </el-col>
                                    </el-row>
                                    <!-- 第三行 功能栏 -->
                                    <el-row>
                                        <el-col :span="24" class="table-fun">
                                            <img src="../../assets/imgs/operation_icon_tianjia_default.png" alt=""
                                                 class="lf">
                                            <div class="lf choose-title fun-text">添加</div>
                                            <img src="../../assets/imgs/operation_icon_shanchu_default.png" alt=""
                                                 class="lf">
                                            <div class="lf choose-title fun-text">删除</div>
                                            <img src="../../assets/imgs/Radio_icon_yingyong_default.png" alt=""
                                                 class="lf">
                                            <div class="lf choose-title fun-text">应用</div>
                                        </el-col>
                                    </el-row>
                                    <!-- 数据表格栏 -->
                                    <el-row>
                                        <el-col :span="24" class="contactList-container">
                                            <el-table
                                                    :data="contactList"
                                                    stripe
                                                    style="width: 100%">
                                                <el-table-column
                                                        prop="name"
                                                        label="机构"
                                                        width="250">
                                                </el-table-column>
                                                <el-table-column
                                                        prop="pid"
                                                        label="关联项"
                                                >
                                                </el-table-column>
                                            </el-table>
                                        </el-col>
                                    </el-row>
                                    <!-- 第五行 -->
                                    <el-row class="org-rows org-rowsII">
                                        <el-col :span="24">
                                            <el-select v-model="jiGou" placeholder="" class="lf choose-input org-select"
                                                       size="mini">
                                                <el-option label="顶级机构" value="1"></el-option>
                                                <el-option label="test1" value="2"></el-option>
                                                <el-option label="test2" value="3"></el-option>
                                                <el-option label="test3" value="4"></el-option>
                                            </el-select>
                                            <el-select v-model="sellType" placeholder="" class="rf choose-input"
                                                       size="mini">
                                                <el-option label="优惠类型定义，售票" value="1"></el-option>
                                                <el-option label="test1" value="2"></el-option>
                                                <el-option label="test2" value="3"></el-option>
                                                <el-option label="test3" value="4"></el-option>
                                            </el-select>
                                        </el-col>
                                    </el-row>
                                </div>
                            </el-col>
                        </el-row>
                    </el-col>
                </el-row>
                <!-- 按钮 -->
                <button class="check-btn rf" @click="cancelMod">
                    <img src="../../assets/imgs/operation_btn_icon_quxiao_default.png" alt="" class="btn-img">取消
                </button>
                <button class="check-btn rf" @click="modified"><img
                        src="../../assets/imgs/operation_btn_icon_tijiao_default.png" alt="" class="btn-img">确认
                </button>
            </div>
        </div>
    </div>
</template>

<script>
    import qs from "qs";
    import TableData from "../../components/common/tableData";

    export default {
        data: function () {
            return {
                orgList: [
                    {
                        page: {
                            pageSizes: [10],
                            total: 2,
                            currentPage: 1,
                            pageSize: 10
                        },
                        option: {
                            highlightCurrentRow: true,
                            stripe: true,
                            menu: false,
                            align: "center",
                            menuAlign: "center",
                            data: [],
                            columns: []
                        }
                    }
                ],
                nameChecked: false,
                addWin: false,
                classID: "",
                simpleID: "",
                fullID: "",
                comp: "",
                address: "",
                orgType: "",
                orgTypeList: [],
                fatherOrgList: [],
                fatherOrgType: [],
                regID: "珠暨",
                fontColor: "",
                bgColor: "",
                contactMan: "",
                contactPhone: "",
                remark: "",
                contactList: [],
                jiGou: "1",
                sellType: "1",
                modWin: false,
                delID: {id: "391"},
                guanLianOrgList: [],
                currentRow: ""
            };
        },
        methods: {
            getOrgList() {
                this.postRequest("/sys/org/tree?sort=no&order=asc").then(data => {
                    console.log(data);

                    console.log(data.data[0].children);

                    // this.orgList[0].data = data.data[0].children;

                    var tag = data.data;

                    if (tag.length >0){
                        for (var i = 0; i < tag.length; i++) {
                            console.log(tag[i].name);
                            var tag1 = tag[i].children;
                             for(var k = 0; k < tag1.length; k++){
                                 var tag2 = tag[k].children;
                                 for(var j = 0; j < tag2.length; j++){
                                     this.orgList[0].option.data.push(
                                         {
                                             name: tag[i].name,
                                             no: tag[i].no,
                                             name_full: tag[i].name_full,
                                             org_type: tag[i].org_type,
                                             fontcolor: tag[i].fontcolor,
                                             bgcolor: tag[i].bgcolor,
                                             data_link_level: tag[i].data_link_level,
                                             data_link_org_ids: tag[i].data_link_org_ids,
                                             addr: tag[i].addr,
                                             children: [
                                                 {
                                                     name: tag1[k].name,
                                                     pid: tag1[k].pid,
                                                     name_full: tag1[k].name_full,
                                                     org_type: tag1[k].org_type,
                                                     fontcolor: tag1[k].fontcolor,
                                                     bgcolor: tag1[k].bgcolor,
                                                     data_link_level: tag1[k].data_link_level,
                                                     data_link_detail: tag1[k].data_link_detail,
                                                     salecount: tag1[k].salecount,
                                                     children: [
                                                         {
                                                             name: tag2[j].name,
                                                             pid: tag2[j].pid,
                                                             name_full: tag2[j].name_full,
                                                             org_type: tag2[j].org_type,
                                                             fontcolor: tag2[j].fontcolor,
                                                             bgcolor: tag2[j].bgcolor,
                                                             data_link_level: tag2[j].data_link_level,
                                                             data_link_detail: tag2[j].data_link_detail,
                                                             salecount: tag2[j].salecount,
                                                         }
                                                     ]
                                                 }
                                             ]
                                         })
                                 }

                             }
                        }
                    }
                    console.log(this.orgList[0].data);

                });
            },
            getOrgTypeList() {
                this.orgList[0].data = [];
                this
                    .postRequest("/sch/data/common/orgtype")
                    .then(data => {
                        for (var item of data.data) {
                            this.orgTypeList.push({
                                label: item.key,
                                value: item.value
                            });
                        }
                    });
            },
            getFatherOrgList() {
                this.fatherOrgList = [];
                this.postRequest("/sys/org/list").then(data => {
                    for (var item of data.data.list) {
                        this.fatherOrgList.push({
                            label: item.name,
                            value: item.pid
                        });
                    }
                });
            },
            closeAddWin() {
                this.addWin = false;
            },
            refresh() {
                this.getOrgList();
            },
            add() {
                this.addWin = true;
            },
            cancel() {
                this.addWin = false;
            },
            confirm() {
                this
                    .getRequest(
                        "/sys/org/add?sysOrg.id=&sysOrg.no=" + this.classID + "&sysOrg.pid=" + this.classID + "&sysOrg.name=" + this.fatherOrgType + "&sysOrg.org_type=" + this.orgType + "&sysOrg.name_full=" + this.fullID + "&sysOrg.data_link_level=&sysOrg.data_link_org_ids=&sysOrg.code=" + this.regID + "&sysOrg.bgcolor=" + this.bgColor + "&sysOrg.fontcolor=" + this.fontColor + "&sysOrg.contacts=" + this.contactMan + "&sysOrg.telephone=" + this.contactPhone + "&sysOrg.company=" + this.comp + "&sysOrg.addr=" + this.address + "&sysOrg.memo=" + this.remark + "&sysOrg.data_link_detail=&linked_org_name=" + this.orgType + "&linked_data_names=&linked_data_ids=&linked_org_id=&linked_org_name=&linked_data_names=&linked_data_ids=&linked_org_id=&sysOrg.data_link_org_names="
                    )
                    .then(data => {
                        this.msgShow(data, function () {
                            this.addModal = false;
                        });
                    });
            },
            mod() {
                this.modWin = true;
            },
            closeModWin() {
                this.modWin = false;
            },
            cancelMod() {
                this.modWin = false;
            },
            modified() {
                this
                    .getRequest(
                        "/sys/org/update?sysOrg.id=&sysOrg.no=" + this.classID + "&sysOrg.pid=" + this.classID + "&sysOrg.name=" + this.fatherOrgType + "&sysOrg.org_type=" + this.orgType + "&sysOrg.name_full=" + this.fullID + "&sysOrg.data_link_level=&sysOrg.data_link_org_ids=&sysOrg.code=" + this.regID + "&sysOrg.bgcolor=" + this.bgColor + "&sysOrg.fontcolor=" + this.fontColor + "&sysOrg.contacts=" + this.contactMan + "&sysOrg.telephone=" + this.contactPhone + "&sysOrg.company=" + this.comp + "&sysOrg.addr=" + this.address + "&sysOrg.memo=" + this.remark + "&sysOrg.data_link_detail=&linked_org_name=" + this.orgType + "&linked_data_names=&linked_data_ids=&linked_org_id=&linked_org_name=&linked_data_names=&linked_data_ids=&linked_org_id=&sysOrg.data_link_org_names="
                    )
                    .then(data => {
                        if (data.data[0] == 0) {
                            this.$message({
                                message: data.data[1],
                                type: "success"
                            });
                            this.getOrgList();
                            this.addModal = false;
                        } else {
                            this.$message.error(data.data[1]);
                        }
                    });
            },
            del() {
                this
                    .postRequest(
                        "/sys/org/del", {
                            id: this.currentRow.id
                        }
                    )
                    .then(data => {
                        if (data.data[0] == 0) {
                            this.$message({
                                message: data.data[1],
                                type: "success"
                            });
                            this.getOrgList();
                        } else {
                            this.$message.error(data.data[1]);
                        }
                    });
            },
            tableCreate() {
                this.orgList[0].option.columns.push(
                    {
                        text: "简称",
                        value: "name"
                    },
                    {
                        text: "机构编号",
                        value: "no"
                    },
                    {
                        text: "全称",
                        value: "name_full"
                    },
                    {
                        text: "机构类型",
                        value: "org_type"
                    },
                    {
                        text: "字体颜色",
                        value: "fontcolor"
                    },
                    {
                        text: "背景颜色",
                        value: "bgcolor"
                    },
                    {
                        text: "数据关联级别",
                        value: "data_link_level"
                    },
                    {
                        text: "数据关联机构",
                        value: "data_link_org_ids"
                    },
                    {
                        text: "地址",
                        value: "addr"
                    }
                );
            },
            getguanLianOrgList() {
                this.postRequest("/sys/org/list").then(data => {
                    this.guanLianOrgList = data.data.list;
                })
            },
            rowChange(val) {
                this.currentRow = val;
            }
        },
        computed: {},
        components: {TableData},
        watch: {},
        mounted() {
            console.log("orgManage");
            this.$emit("sendActive", "1-1");
            this.tableCreate();
            this.getOrgList();
            this.getOrgTypeList();
            this.getFatherOrgList();
            this.getguanLianOrgList();
        }
    };
</script>
<style scoped src="../../assets/css/allManage/orgManage.css">
</style>
